
#ifndef _KEY_H_
#define _KEY_H_

#include "includes\types.h"
#include "includes\ca51f3sfr.h"
#include "includes\ca51f3xsfr.h"

sbit H1=P1^1;  
sbit H2=P1^2;  
sbit H3=P1^3;  

sbit V1=P1^0;  
sbit V2=P1^4;  
sbit V3=P1^5;  
sbit V4=P1^6; 



#define RESET        0

#define NO_KEY			 	0x00
#define KEY1_DOWN			0x01
#define KEY2_DOWN			0x02
#define KEY3_DOWN			0x03
#define KEY4_DOWN			0x04
#define KEY5_DOWN			0x05
#define KEY6_DOWN			0x06
#define KEY7_DOWN			0x07
#define KEY8_DOWN			0x08
#define KEY9_DOWN			0x09
#define KEY10_DOWN		0x0A
#define KEY11_DOWN		0x0B
#define KEY12_DOWN		0x0C
#define KEY13_DOWN		0x0D

#define KEY_UP			0xA0
#define KEY_SURE		0xB0
#define KEY_DOWN		0xC0
#define KEY_LONG1		0xD0

#define KEY1_ONE_DOWN		0xC1
#define KEY2_ONE_DOWN		0xC2
#define KEY3_ONE_DOWN		0xC3
#define KEY4_ONE_DOWN		0xC4
#define KEY5_ONE_DOWN		0xC5
#define KEY6_ONE_DOWN		0xC6
#define KEY7_ONE_DOWN		0xC7
#define KEY8_ONE_DOWN		0xC8
#define KEY9_ONE_DOWN		0xC9
#define KEY10_ONE_DOWN	0xCA
#define KEY11_ONE_DOWN	0xCB
#define KEY12_ONE_DOWN	0xCC
#define KEY13_ONE_DOWN	0xCD

#define KEY1_LONG_DOWN	0xD1
#define KEY2_LONG_DOWN	0xD2
#define KEY3_LONG_DOWN	0xD3
#define KEY4_LONG_DOWN	0xD4
#define KEY5_LONG_DOWN	0xD5
#define KEY6_LONG_DOWN	0xD6
#define KEY7_LONG_DOWN	0xD7
#define KEY8_LONG_DOWN	0xD8
#define KEY9_LONG_DOWN	0xD9
#define KEY10_LONG_DOWN	0xDA
#define KEY11_LONG_DOWN	0xDB
#define KEY12_LONG_DOWN	0xDC
#define KEY13_LONG_DOWN	0xDD

void key_io_init(void);

uchar GetKEY(void);
uchar ReadKeyStatus(void);


#endif

